package com.mgface.framework.springboot.web;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mgface.framework.metrics.SBDMetrics;

@RestController
@ConditionalOnExpression(value="${sbd.enabled.mapping}==true")
public class ConditionBySpELController {
	private final static Logger log = LogManager.getLogger(ConditionBySpELController.class);
	@Autowired
	private SBDMetrics sbdMetrics;
	@RequestMapping(value = "/spel")
	private String spel() {
		sbdMetrics.invokeMethod();//调用指标
		log.info("启用SpEL访问,开始时间<{}>", LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
		return "spel";
	}
}
